<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8"> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <meta name="apple-mobile-web-app-capable" content="yes" />

        <!-- Base Css Files -->
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/jqueryui/ui-lightness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/fontello/css/fontello.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/animate-css/animate.min.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/nifty-modal/css/component.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/magnific-popup/magnific-popup.css" rel="stylesheet" /> 
        <link href="__PUBLIC__/statics/coco-chat/assets/css/style.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/statics/coco-chat/assets/css/style-responsive.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/pace/pace.css" rel="stylesheet" />
        <link href="__PUBLIC__/statics/coco-chat/assets/libs/jquery-notifyjs/styles/metro/notify-metro.css" rel="stylesheet" type="text/css" />
        
        <!-- Extra CSS Files -->
      	<link href="__PUBLIC__/statics/coco-chat/assets/libs/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
        
        <!-- Custom Css Files -->
        <link href="__ADMIN_CSS__/style.css"  rel="stylesheet" />
    </head>
    
    <body>
    <div>
        <div class="sub-header-title">
            <h2>公告列表</h2>
        </div>
        <form method="post" class="form-horizontal" action="{:U('News/index')}">
       		<div class="form-group">
	            <div class="col-sm-2">
                   	<select class="form-control selectpicker" name="news_category_id">
                 		<option value="0">全部分类</option>
                      	<volist name="categorys" id="vo">
                          	<option value="{$vo.id}" <if condition="$news_category_id eq $vo['id']">selected</if> >{$vo.title}</option>
                      	</volist>
                  	</select>
               	</div>
	       		<div class="col-sm-2">
                   	<div class="input-group">
                       	<span class="input-group-addon">日期</span>
                       	<input class="form-control" id="date-start" name="date_start" value="{$date_start}" type="text" placeholder="开始日期"/>
                   	</div>
               	</div>
               	<div class="col-sm-2">
                   	<div class="input-group">
                       	<span class="input-group-addon">-</span>
                       	<input class="form-control" id="data-end" name="date_end" value="{$date_end}" type="text" placeholder="截止日期"/>
                   	</div>
               	</div>
	            <div class="col-sm-2">
                   	<input class="form-control" id="filter" placeholder="根据公告标题搜索" name="title" value="{$title}" type="text"/>
               	</div>
	            
	            <div class="col-sm-2">
                   	<button class="btn btn-success" type="submit">查询</button>
               	</div>
               	<div class="col-sm-2">
	                <a class="btn btn-success pull-right" href="{:U('News/add')}">发布公告</a>
	            </div>
	        </div>
        </form>
    </div>
    <div class="widget">
        <div class="widget-content">                            
            <table id="user" class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>标题</th>
                        <th>所属分类</th>
                        <th>添加时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="datahtml"> 
                     <volist name="datainfo" id="vo">
                        <tr>         
                            <td>{$vo.title}</td>
                            <td>{$vo.categoty.title}</td>
                            <td>{$vo.add_time}</td>
                            <td data-id="{$vo.id}">
								<a href="{:U('News/edit',array('id'=>$vo['id']))}">修改</a> |
								<a href="javascript:void(0);" class="new-delete">删除</a>
								<!-- <a href="{:U('News/addNews',array('newsid'=>$vo['id'],'flag'=>'selectnews'))}">查看</a> -->
							</td>
                        </tr>
                     </volist>  
                </tbody>
            </table>
            {$page}
        </div> 
    </div> 
    
    <!-- Base Js Files -->
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery/jquery-1.11.1.min.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/bootstrap/js/bootstrap.min.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jqueryui/jquery-ui-1.10.4.custom.min.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery-ui-touch/jquery.ui.touch-punch.min.js"></script>
 	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery-detectmobile/detect.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/fastclick/fastclick.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery-slimscroll/jquery.slimscroll.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/nifty-modal/js/classie.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/nifty-modal/js/modalEffects.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery-notifyjs/notify.min.js"></script>
    <script src="__PUBLIC__/statics/coco-chat/assets/libs/jquery-notifyjs/styles/metro/notify-metro-blue.js"></script>
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/pace/pace.min.js"></script>
	
	<!-- Extra Js Files -->
	<script src="__PUBLIC__/statics/coco-chat/assets/libs/bootstrap-select/bootstrap-select.min.js"></script>
    <script src="__PUBLIC__/statics/coco-chat/assets/libs/bootstrap-select2/select2.min.js"></script>
    <script src="__PUBLIC__/statics/coco-chat/assets/libs/laydate/laydate.js"></script>
	
	<!-- Custom Js Files -->
	<script src="__ADMIN_JS__/common.js"></script>
	
    <script>
  		var start = {
          	elem: '#date-start', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        	event: 'focus', //响应事件。如果没有传入event，则按照默认的click
        	max: laydate.now(), //最大日期
          	choose: function(datas){
            	end.min = datas; //开始日选好后，重置结束日的最小日期
            	end.start = datas //将结束日的初始值设定为开始日
          	}
      	};
      	var end = {
          	elem: '#data-end', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        	event: 'focus', //响应事件。如果没有传入event，则按照默认的click
        	max: laydate.now(), //最大日期
          	choose: function(datas){
            	start.max = datas; //结束日选好后，重置开始日的最大日期
          	}
      	};
      	laydate(start);
      	laydate(end);
      	
      	//SELECT
        $('.selectpicker').selectpicker();
        
      	//删除新闻公告
		$('.new-delete').click(function() {
			var id = $(this).parent('td').data("id");
			
			window.parent.layer.confirm('删除后将无法恢复，确认删除该公告吗？', {
				btn: ['确认','取消'] //按钮
			}, function(index){
				// 用ajax提交表单
				$.post("{:U('News/del')}", 'id='+id, function(response) {
					//弹出提示
					window.parent.layer.msg(response.message);

					//根据请求相应状态提示通知
					if(response.status){
						notify("success",response.message);
						window.location.reload();
					}else{
						notify("error",response.message);
					}
				}, 'json');
				//关闭确认对话框
				window.parent.layer.close(index);
			});
		});
	</script>
	</body>
</html>